<?php


/*
* Copyright (c) 2008-2016 vip.com, All Rights Reserved.
*
* Powered by com.vip.osp.osp-idlc-2.5.11.
*
*/

namespace com\vip\lbs\api\service\printtemplate;

class LbsPrinterEventModel {
	
	static $_TSPEC;
	public $printerVersion = null;
	public $eventSource = null;
	public $eventTypes = null;
	public $eventTime = null;
	public $eventLevel = null;
	public $fingerprint = null;
	public $eventPayload = null;
	public $traceId = null;
	public $contentType = null;
	
	public function __construct($vals=null){
		
		if (!isset(self::$_TSPEC)){
			
			self::$_TSPEC = array(
			1 => array(
			'var' => 'printerVersion'
			),
			2 => array(
			'var' => 'eventSource'
			),
			3 => array(
			'var' => 'eventTypes'
			),
			4 => array(
			'var' => 'eventTime'
			),
			5 => array(
			'var' => 'eventLevel'
			),
			6 => array(
			'var' => 'fingerprint'
			),
			7 => array(
			'var' => 'eventPayload'
			),
			8 => array(
			'var' => 'traceId'
			),
			9 => array(
			'var' => 'contentType'
			),
			
			);
			
		}
		
		if (is_array($vals)){
			
			
			if (isset($vals['printerVersion'])){
				
				$this->printerVersion = $vals['printerVersion'];
			}
			
			
			if (isset($vals['eventSource'])){
				
				$this->eventSource = $vals['eventSource'];
			}
			
			
			if (isset($vals['eventTypes'])){
				
				$this->eventTypes = $vals['eventTypes'];
			}
			
			
			if (isset($vals['eventTime'])){
				
				$this->eventTime = $vals['eventTime'];
			}
			
			
			if (isset($vals['eventLevel'])){
				
				$this->eventLevel = $vals['eventLevel'];
			}
			
			
			if (isset($vals['fingerprint'])){
				
				$this->fingerprint = $vals['fingerprint'];
			}
			
			
			if (isset($vals['eventPayload'])){
				
				$this->eventPayload = $vals['eventPayload'];
			}
			
			
			if (isset($vals['traceId'])){
				
				$this->traceId = $vals['traceId'];
			}
			
			
			if (isset($vals['contentType'])){
				
				$this->contentType = $vals['contentType'];
			}
			
			
		}
		
	}
	
	
	public function getName(){
		
		return 'LbsPrinterEventModel';
	}
	
	public function read($input){
		
		$input->readStructBegin();
		while(true){
			
			$schemeField = $input->readFieldBegin();
			if ($schemeField == null) break;
			$needSkip = true;
			
			
			if ("printerVersion" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->printerVersion);
				
			}
			
			
			
			
			if ("eventSource" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->eventSource);
				
			}
			
			
			
			
			if ("eventTypes" == $schemeField){
				
				$needSkip = false;
				
				$this->eventTypes = array();
				$_size0 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem0 = null;
						$input->readString($elem0);
						
						$this->eventTypes[$_size0++] = $elem0;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			
			if ("eventTime" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->eventTime);
				
			}
			
			
			
			
			if ("eventLevel" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->eventLevel);
				
			}
			
			
			
			
			if ("fingerprint" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->fingerprint);
				
			}
			
			
			
			
			if ("eventPayload" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->eventPayload);
				
			}
			
			
			
			
			if ("traceId" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->traceId);
				
			}
			
			
			
			
			if ("contentType" == $schemeField){
				
				$needSkip = false;
				$input->readByte($this->contentType); 
				
			}
			
			
			
			if($needSkip){
				
				\Osp\Protocol\ProtocolUtil::skip($input);
			}
			
			$input->readFieldEnd();
		}
		
		$input->readStructEnd();
		
		
		
	}
	
	public function write($output){
		
		$xfer = 0;
		$xfer += $output->writeStructBegin();
		
		if($this->printerVersion !== null) {
			
			$xfer += $output->writeFieldBegin('printerVersion');
			$xfer += $output->writeString($this->printerVersion);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->eventSource !== null) {
			
			$xfer += $output->writeFieldBegin('eventSource');
			$xfer += $output->writeString($this->eventSource);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->eventTypes !== null) {
			
			$xfer += $output->writeFieldBegin('eventTypes');
			
			if (!is_array($this->eventTypes)){
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$output->writeListBegin();
			foreach ($this->eventTypes as $iter0){
				
				$xfer += $output->writeString($iter0);
				
			}
			
			$output->writeListEnd();
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->eventTime !== null) {
			
			$xfer += $output->writeFieldBegin('eventTime');
			$xfer += $output->writeString($this->eventTime);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->eventLevel !== null) {
			
			$xfer += $output->writeFieldBegin('eventLevel');
			$xfer += $output->writeString($this->eventLevel);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->fingerprint !== null) {
			
			$xfer += $output->writeFieldBegin('fingerprint');
			$xfer += $output->writeString($this->fingerprint);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->eventPayload !== null) {
			
			$xfer += $output->writeFieldBegin('eventPayload');
			$xfer += $output->writeString($this->eventPayload);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->traceId !== null) {
			
			$xfer += $output->writeFieldBegin('traceId');
			$xfer += $output->writeString($this->traceId);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->contentType !== null) {
			
			$xfer += $output->writeFieldBegin('contentType');
			$xfer += $output->writeByte($this->contentType);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		$xfer += $output->writeFieldStop();
		$xfer += $output->writeStructEnd();
		return $xfer;
	}
	
}

?>